#include "Primitives.h"

Vec3D cube_verts[] = 
{
	{	-1.0f, -1.0f,  1.0f	},	//Frontface
	{	1.0f, -1.0f,  1.0f	},
	{	 1.0f,  1.0f,  1.0f	},
	{   -1.0f,  1.0f,  1.0f	},

	{	-1.0f, -1.0f,	-1.0f,	},	//Backface
	{	-1.0f,	1.0f,	-1.0f,	},
	{	 1.0f,  1.0f,	-1.0f,	},
	{    1.0f, -1.0f,	-1.0f,	},

	{	-1.0f,	1.0f,	-1.0f,	},	//Topface 
	{	-1.0f,	1.0f,	 1.0f,	},
	{	1.0f,	1.0f,	 1.0f,	},
	{	1.0f,	1.0f,	-1.0f,	},

	{	-1.0f,	-1.0f,  -1.0f,	},	//Bottom face
	{	1.0f,	-1.0f,	-1.0f,	},
	{	1.0f,	-1.0f,	1.0f,	},
	{	-1.0f,	-1.0f,	1.0f,	},

	{	-1.0f,	-1.0f,	-1.0f,	},	//Left face
	{	-1.0f,	-1.0f,	1.0f,	},
	{	-1.0f,	1.0f,	1.0f,	},
	{	-1.0f,	1.0f,	-1.0f,	},

	{	1.0f,	-1.0f,	-1.0f,	},	//Right face
	{	1.0f,	 1.0f,	-1.0f,	},
	{	1.0f,	 1.0f,	1.0f,	},
	{	1.0f,	-1.0f,	1.0f,	},
};

Vec2D cube_tex_coords[] = 
{
	{	0.0,	1.0f,	},
	{	1.0f,	1.0f,	},
	{	1.0f,	0.0f,	},
	{	0.0f,	0.0f,	},

	{	1.0,	0.0f,	},
	{	0.0f,	0.0f,	},
	{	0.0f,	1.0f,	},
	{	1.0f,	1.0f,	},

	{	0.0f,	1.0f,	},
	{	0.0f,	0.0f,	},
	{	1.0f,	0.0f,	},
	{	1.0f,	1.0f,	},

	{	0.0f,	1.0f,	},
	{	0.0f,	0.0f,	},
	{	1.0f,	0.0f,	},
	{	1.0f,	1.0f,	},

	{	0.0f,	1.0f,	},
	{	0.0f,	0.0f,	},
	{	1.0f,	0.0f,	},
	{	1.0f,	1.0f,	},

	{	0.0f,	1.0f,	},
	{	0.0f,	0.0f,	},
	{	1.0f,	0.0f,	},
	{	1.0f,	1.0f,	},
};
/*
Vec3D pyramide_verts[] = 							
{ 
	{ 0.0f, 1.0f, 0.0f},					
	{-1.0f,-1.0f, 1.0f},					
	{ 1.0f,-1.0f, 1.0f},					

	{ 0.0f, 1.0f, 0.0f},					
	{ 1.0f,-1.0f, 1.0f},				
	{ 1.0f,-1.0f, -1.0f},				
	
	{ 0.0f, 1.0f, 0.0f},					
	{ 1.0f,-1.0f, -1.0f},				
	{-1.0f,-1.0f, -1.0f},				
	
	{ 0.0f, 1.0f, 0.0f},					
	{-1.0f,-1.0f,-1.0f},					
	{-1.0f,-1.0f, 1.0f},		
};
*/

void PRIMITIVE::MakeCube(void)
{
    glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	
	glVertexPointer(3, GL_FLOAT, 0, cube_verts);	
	glTexCoordPointer(2, GL_FLOAT, 0, cube_tex_coords);

	//glLockArraysEXT(0, 24);

	glDisableClientState(GL_VERTEX_ARRAY);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}

void PRIMITIVE::DrawCube(void)
{
	 glEnableClientState(GL_VERTEX_ARRAY);
	 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	
	 glDrawArrays(GL_QUADS, 0, 24);

	 glDisableClientState(GL_VERTEX_ARRAY);
	 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
